<!DOCTYPE html>
<html>
<!--
Copyright 2011 The Closure Library Authors. All Rights Reserved.

Use of this source code is governed by the Apache License, Version 2.0.
See the COPYING file for details.

-->
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Closure Unit Tests - goog.storage.mechanism.HTML5LocalStorage</title>
<script src="../../base.js"></script>
<script>
  goog.require('goog.storage.mechanism.iterablemechanism_test');
  goog.require('goog.storage.mechanism.prefixedmechanism_test');
  goog.require('goog.storage.mechanism.mechanism_test');
  goog.require('goog.storage.mechanism.HTML5LocalStorage');
  goog.require('goog.testing.jsunit');
  goog.require('goog.userAgent');
</script>
</head>
<body>
<script>

function testAvailability() {
  var mechanism = new goog.storage.mechanism.HTML5LocalStorage();
  if (goog.userAgent.WEBKIT && goog.userAgent.isVersion('532.5') ||
      goog.userAgent.GECKO && goog.userAgent.isVersion('1.9.1') ||
      goog.userAgent.IE && goog.userAgent.isVersion('8')) {
    assertTrue(mechanism.isAvailable());
  }
}

function testBasicOperations() {
  var mechanism = new goog.storage.mechanism.HTML5LocalStorage();
  if (mechanism.isAvailable()) {
    goog.storage.mechanism.mechanism_test.runBasicTests(mechanism);
  }
}

function testIterableOperations() {
  var mechanism = new goog.storage.mechanism.HTML5LocalStorage();
  if (mechanism.isAvailable()) {
    goog.storage.mechanism.iterablemechanism_test.runIterableTests(mechanism);
  }
}

function testSharing() {
  var mechanismA = new goog.storage.mechanism.HTML5LocalStorage();
  if (mechanismA.isAvailable()) {
    var mechanismB = new goog.storage.mechanism.HTML5LocalStorage();
    assertTrue(mechanismB.isAvailable());
    goog.storage.mechanism.prefixedmechanism_test.runSharingTests(
        mechanismA, mechanismB);
  }
}

function testQuota() {
  var mechanism = new goog.storage.mechanism.HTML5LocalStorage();
  if (mechanism.isAvailable()) {
    // There should be at least 4 MiB.
    goog.storage.mechanism.mechanism_test.runQuotaTests(
        mechanism, 4 * 1024 * 1024);
  }
}

// This is disabled because it is only suitable for manual testing
function flaky_testPersistence() {
  var mechanism = new goog.storage.mechanism.HTML5LocalStorage();
  if (mechanism.isAvailable()) {
    goog.storage.mechanism.mechanism_test.runPersistenceTests(mechanism);
  }
}

</script>
</body>
</html>
